<template>
  <div class="hotel-main">
    <div class="commercial" ref="commercial">
      <img
        src="https://images.mafengwo.net/images/hotel/pc_app_guide/qrcode_new_user_coupon.png"
        class="commercialImg"
      />
      <span class="commercialDown" @click="commercialDown">×</span>
    </div>
    <div class="h-title">订酒店</div>

    <!-- 输入框 -->
    <div class="date-warp">
      <input
        type="text"
        class="destinationIpt input"
        placeholder="出行目的地"
        ref="input"
        v-model="searchValue"
        @focus="initialBlock('block', $event)"
        @click.stop
      />
      <!-- 获取焦点弹出框 (出行目的地)-->
      <div class="not-cont" ref="initialBox" @click.stop>
        <div class="cont-item">
          <div class="countryName">中国</div>
          <div class="cityList">
            <a href="javascript:;">台北</a>
            <a href="javascript:;">香港</a>
            <a href="javascript:;">澳门</a>
            <a href="javascript:;">武汉</a>
            <a href="javascript:;">北京</a>
            <a href="javascript:;">上海</a>
            <a href="javascript:;">深圳</a>
            <a href="javascript:;">佛山</a>
            <a href="javascript:;">大连</a>
            <a href="javascript:;">重庆</a>
          </div>
        </div>
        <div class="cont-item">
          <div class="countryName">中国</div>
          <div class="cityList">
            <a href="javascript:;">台北</a>
            <a href="javascript:;">香港</a>
            <a href="javascript:;">澳门</a>
            <a href="javascript:;">武汉</a>
            <a href="javascript:;">北京</a>
            <a href="javascript:;">上海</a>
            <a href="javascript:;">深圳</a>
            <a href="javascript:;">佛山</a>
            <a href="javascript:;">大连</a>
            <a href="javascript:;">重庆</a>
          </div>
        </div>
        <div class="cont-item">
          <div class="countryName">中国</div>
          <div class="cityList">
            <a href="javascript:;">台北</a>
            <a href="javascript:;">香港</a>
            <a href="javascript:;">澳门</a>
            <a href="javascript:;">武汉</a>
            <a href="javascript:;">北京</a>
            <a href="javascript:;">上海</a>
            <a href="javascript:;">深圳</a>
            <a href="javascript:;">佛山</a>
            <a href="javascript:;">大连</a>
            <a href="javascript:;">重庆</a>
          </div>
        </div>
        <div class="cont-item">
          <div class="countryName">中国</div>
          <div class="cityList">
            <a href="javascript:;">台北</a>
            <a href="javascript:;">香港</a>
            <a href="javascript:;">澳门</a>
            <a href="javascript:;">武汉</a>
            <a href="javascript:;">北京</a>
            <a href="javascript:;">上海</a>
            <a href="javascript:;">深圳</a>
            <a href="javascript:;">佛山</a>
            <a href="javascript:;">大连</a>
            <a href="javascript:;">重庆</a>
          </div>
        </div>
      </div>
      <input type="date" class="initialData input" placeholder="入住日期" />
      <input type="date" class="lastData input" placeholder="离店日期" />
      <div class="peopleNum input" @click.stop="propleBlock">
        <span class="peopleText">人数未定</span>
        <span class="iconfont icon-yonghu"></span>
        <!-- 点击弹出选择人数 -->
        <div class="peopleSelect" ref="propleBox" @click.stop>
          <div class="select">
            <div class="select-top">
              <span class="label">每间</span>
              <select name="adult" value="">
                <option :value="item" v-for="(item, index) in 7" :key="index">
                  {{ item }}
                </option></select
              >成人
              <select name="child" value="">
                <option :value="item" v-for="(item, index) in 6" :key="index">
                  {{ item }}
                </option></select
              >儿童
            </div>
            <div class="select-bottom">
              <span class="label">儿童年龄</span>
              <select name="childAge" value="">
                <option value="<1">&lt;1</option>
                <option :value="index" v-for="(item, index) in 16" :key="index">
                  {{ item }}
                </option>
              </select>
            </div>
          </div>
          <div class="selectBtn">
            <button>确认</button>
          </div>
        </div>
      </div>

      <button
        class="searchBtn input iconfont icon-sousuo"
        @click="searchToAddress"
      ></button>
    </div>

    <!-- 静态文本 -->
    <div class="h-notice">
      <div class="notice-item">
        <i class="iconfont icon-zhinan"></i>
        <div>
          <h2>住宿攻略</h2>
          <p>区域攻略到特色主体,应有尽有</p>
        </div>
      </div>
      <div class="notice-item">
        <i class="iconfont icon-qian"></i>
        <div>
          <h2>专享价格</h2>
          <p>多平台价格对比,天天享受优惠</p>
        </div>
      </div>
      <div class="notice-item">
        <i class="iconfont icon-yonghuliebiao"></i>
        <div>
          <h2>真实点评</h2>
          <p>超过100万真实用户点评和游记</p>
        </div>
      </div>
    </div>
    <!-- 主题住宿 -->
    <div class="h-title" style="text-align: center; margin: 50px 0 25px 0">
      主题住宿
    </div>
    <div class="h-theme">
      <div class="themeList" @click="tabList($event, 1)">
        <a
          href="javascript:;"
          :data-id="index"
          :class="{ on: count == index }"
          v-for="(item, index) in ThemeAccommodation"
          :key="item.id"
        >
          {{ item.name }}
        </a>
      </div>
      <div class="_j_tab_content">
        <ul class="block">
          <li
            v-for="(item, index) in getCountList"
            :key="index"
            @click="toAddressDetail(index)"
          >
            <img :src="item.picUrl" />
            <div class="imageText">
              <h2>{{ item.address }}</h2>
              <p>{{ item.country }}</p>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!--  -->
    <div class="h-title" style="text-align: center; margin: 50px 0 25px 0">
      特价酒店
    </div>
    <div class="h-theme">
      <div class="themeList" @click="tabList($event, 2)">
        <a
          href="javascript:;"
          :data-id="index"
          :class="{ on: twoCount == index }"
          v-for="(item, index) in SpecialHotel"
          :key="item.id"
        >
          {{ item.name }}
        </a>
      </div>
      <div class="wineshopList">
        <ul>
          <li v-for="item in getTwoCountList" :key="item.id">
            <div class="wineshopImg">
              <img :src="item.picUrl" />
            </div>
            <div class="mark">{{ item.score }}分</div>
            <div class="textBox">
              <p class="wineshopName">
                {{ item.name }}
              </p>
              <p class="wineshopEngName">{{ item.text }}</p>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { getBookToHotel } from "../../api/orderWinehouse";
export default {
  name: "OrderWinehouse",
  data() {
    return {
      count: "0",
      twoCount: "0",
      searchValue: "",
      SpecialHotel: [],
      ThemeAccommodation: [],
      getCountList: [],
      getTwoCountList: [],
    };
  },
  created() {},
  async mounted() {
    let res = await getBookToHotel();
    this.SpecialHotel = res.data[0].SpecialHotel.list;
    this.ThemeAccommodation = res.data[0].ThemeAccommodation.list;
    this.getCountList = this.ThemeAccommodation[+this.count].listItem;
    this.getTwoCountList = this.SpecialHotel[+this.twoCount].listItem;
    window.onclick = () => {
      this.$refs.propleBox.style.display = "none";
      this.$refs.input.blur();
      this.$refs.initialBox.style.display = "none";
    };
  },
  methods: {
    tabList(e, count) {
      console.log(this.SpecialHotel[+this.twoCount].listItem);
      if (count === 1) {
        this.count = e.target.getAttribute("data-id");
        this.getCountList = this.ThemeAccommodation[+this.count].listItem;
        return;
      }
      this.twoCount = e.target.getAttribute("data-id");
      this.getTwoCountList = this.SpecialHotel[+this.twoCount].listItem;
    },
    initialBlock(isShow, e) {
      e.stopPropagation();
      this.$refs.initialBox.style.display = isShow;
    },
    propleBlock() {
      this.$refs.propleBox.style.display = "block";
    },
    commercialDown() {
      this.$refs.commercial.style.display = "none";
    },
    toAddressDetail(index) {
      let text =
        this.getCountList[+index].country + this.getCountList[+index].address;
      this.$router.push({
        name: "AddressDetail",
        query: {
          text,
        },
      });
    },
    searchToAddress() {
      if (!this.searchValue) {
        alert("搜索内容不能为空");
        return;
      }
      this.$router.push({
        name: "AddressDetail",
        query: {
          text: this.searchValue,
        },
      });
    },
  },
  computed: {},
};
</script>

<style scoped>
@import url("./iconfont/iconfont.css");

.hotel-main {
  width: 1000px;
  margin: 0 auto;
  padding-top: 60px;
}
.h-title {
  font-size: 24px;
  line-height: 30px;
}
.date-warp {
  position: relative;
  display: flex;
  justify-content: space-between;
  margin: 40px 0 70px 0;
}
.not-cont {
  position: absolute;
  display: none;
  top: 100%;
  width: 725px;
  padding: 25px 10px 0;
  border: 1px solid #999;
  border-radius: 5px;
  background-color: white;
  z-index: 3;
}
.cont-item {
  display: flex;
}
.cont-item .countryName {
  width: 70px;
  flex-shrink: 0;
  padding-left: 10px;
  color: #666;
  font-size: 14px;
  font-weight: 900;
}
.cont-item .cityList {
  display: flex;
  flex-wrap: wrap;
}
.cont-item .cityList a {
  width: 107px;
  padding-bottom: 15px;
  color: #666;
  text-decoration: none;
}
.cont-item .cityList a:hover {
  color: #ff8a00;
}
.input {
  outline: none;
  height: 45px;
  padding: 0;
  border: 1px solid #999;
  border-radius: 4px;
  font-size: 16px;
}
.input:focus {
  border-color: orange;
}
.destinationIpt {
  width: 340px;
  padding-left: 10px;
}
.initialData,
.lastData {
  width: 170px;
  padding-left: 15px;
  cursor: pointer;
}
.peopleNum {
  position: relative;
  width: 170px;
  padding: 0 15px;
  cursor: pointer;
}
.peopleNum span {
  font-size: 16px;
  color: #999;
  line-height: 46px;
}
.peopleNum .icon-yonghu {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: #999;
}
.peopleNum .peopleSelect {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  width: 480px;
  padding: 0 15px;
  background-color: white;
  border: 1px solid orange;
  border-radius: 4px;
  box-shadow: 1px 0px 3px orange;
}
.peopleNum .peopleSelect .select {
  border-bottom: 1px solid #999;
  padding: 20px 0;
}
.peopleNum .peopleSelect .select .label {
  display: inline-block;
  width: 60px;
  font-size: 12px;
}
.selectBtn {
  padding: 20px;
  height: 28px;
}
.selectBtn button {
  float: right;
  outline: none;
  border: none;
  width: 76px;
  padding: 0;
  border-radius: 3px;
  text-align: center;
  line-height: 28px;
  color: white;
  background-color: #ffa800;
}
.selectBtn button:hover {
  background-color: #ff9d00;
}
.searchBtn {
  width: 46px;
  height: 46px;
  background-color: orange;
  border-radius: 5px;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}
.h-notice {
  display: flex;
  justify-content: space-between;
}
.notice-item {
  display: flex;
}
.notice-item h2 {
  margin: 0;
  font-size: 18px;
  color: #999;
}
.notice-item p {
  font-size: 16px;
  margin: 0;
  margin-top: 4px;
  color: #999;
}
.notice-item i {
  width: 35px;
  height: 42px;
  padding-right: 13px;
  color: #aaa;
  font-size: 40px;
}
.themeList {
  display: flex;
  border-bottom: 1px solid #ccc;
}
.themeList a {
  width: 16.66%;
  line-height: 50px;
  text-decoration: none;
  font-size: 18px;
  text-align: center;
  color: #999;
}
.on {
  color: #ff8a00 !important;
  border-bottom: 3px solid #ff8a00;
  margin-bottom: -2px;
}
.block {
  display: flex !important;
  height: 520px;
  list-style-type: none;
  padding: 0;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
}
._j_tab_content {
  height: 520px;
  padding: 0 0 60px 0;
}
._j_tab_content ul li {
  position: relative;
  font-size: 0;
}
._j_tab_content ul li img {
  width: 318px;
  height: 240px;
  cursor: pointer;
}
._j_tab_content ul li .imageText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  cursor: pointer;
}
._j_tab_content ul li .imageText h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  text-shadow: 2px 1px 1px #000;
  color: white;
}
._j_tab_content ul li .imageText p {
  margin: 0;
  text-align: center;
  font-size: 16px;
  text-shadow: 2px 1px 1px #000;
  color: white;
}
.wineshopList ul {
  list-style-type: none;
  padding: 0;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.wineshopList ul li {
  position: relative;
  width: 240px;
  height: 240px;
  margin-bottom: 16px;
}
.wineshopList .wineshopImg img {
  width: 240px;
  height: 240px;
  cursor: pointer;
}
.wineshopList .mark {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 55px;
  height: 25px;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  font-size: 18px;
  color: white;
  z-index: 2;
}
.wineshopList .textBox {
  position: absolute;
  bottom: 10px;
  left: 10px;
}
.wineshopList .textBox .wineshopName,
.wineshopList .textBox .wineshopEngName {
  margin: 0;
  font-size: 14px;
  text-shadow: 1px 2px 2px #000;
  color: white;
}
.wineshopList .textBox .wineshopEngName {
  font-size: 12px;
}
.commercial {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 150px;
  height: 175px;
}
.commercial .commercialImg {
  width: 100%;
  height: 100%;
}
.commercial .commercialDown {
  position: absolute;
  font-size: 18px;
  top: 10px;
  right: 10px;
  width: 20px;
  line-height: 20px;
  border-radius: 50%;
  text-align: center;
  color: white;
  background-color: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
</style>
